<html>
<head><meta charset="utf-8"><title>clippy.toml · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html">clippy.toml</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="242698057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242698057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242698057">(Jun 15 2021 at 07:43)</a>:</h4>
<p>Hi! Wanted to ask, is there any documentation for <code>clippy.toml</code> / <code>.clippy.toml</code> apart from the clippy readme? In particular, I'm curious whether the file applies both from the workspace root and package root for workspace packages, and what happens when there are is a a config file at both.</p>



<a name="242701411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242701411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242701411">(Jun 15 2021 at 08:19)</a>:</h4>
<p>No, the README is the only documentation. Clippy searches from the current package upwards. It starts at <code>$CLIPPY_CONF_DIR</code> if that env var is set. Otherwise, when using cargo (in most cases) it starts at <a href="https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates"><code>$CARGO_MANIFEST_DIR</code></a>. In all other cases it starts at the current dir.</p>
<p>So if you have a dir structure like this:</p>
<div class="codehilite"><pre><span></span><code>foo
├── bar
│   ├── Cargo.toml
│   ├── clippy.toml
│   └── src
├── Cargo.toml
├── clippy.toml
└── src
</code></pre></div>
<p>And run <code>cargo clippy</code> in <code>bar</code> the <code>clippy.toml</code> file in <code>bar</code> should be used. If you run it in <code>foo</code> then <code>clippy.toml</code> in <code>foo</code> should be used. If you don't have a <code>clippy.toml</code> file in <code>foo</code> OR <code>bar</code>, but in a parent folder of <code>foo</code>, then that file will be used.</p>
<p>(I'm not 100% sure what <code>CARGO_MANIFEST_DIR</code> contains in workspaces depending on where <code>cargo</code> commands are run. It may always contain the path to the top level <code>Cargo.toml</code> file, in that case my explanation is wrong and the <code>clippy.toml</code> file of <code>foo</code> is always used. But if I understand the documentation of <code>CARGO_MANIFEST_DIR</code> correct, than it should contain the path to the current package and my explanation should be correct)</p>



<a name="242703258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242703258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242703258">(Jun 15 2021 at 08:39)</a>:</h4>
<p>Yeah <code>CARGO_MANIFEST_DIR</code> is for the current package, getting the workspace root path requires running <code>cargo metadata</code> and isn't available as an env var</p>



<a name="242703298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242703298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242703298">(Jun 15 2021 at 08:39)</a>:</h4>
<p>So there is no way to have project settings and more fine-grained package setting then, without copying everything from the project config into the more specific ones?</p>



<a name="242703484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242703484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242703484">(Jun 15 2021 at 08:41)</a>:</h4>
<p>Specifically I'd like to use <a href="https://github.com/rust-lang/rust-clippy/pull/7315">disallowed_type</a> to forbid use of <code>HashMap</code> in a few proc-macro crates while keeping a project-wide MSRV and potentially other settings</p>



<a name="242703499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242703499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242703499">(Jun 15 2021 at 08:41)</a>:</h4>
<p>I guess I should open an issue about this.</p>



<a name="242703786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242703786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242703786">(Jun 15 2021 at 08:44)</a>:</h4>
<p>No it just uses the first file it finds and doesn't reuse other files in the workspace.</p>
<blockquote>
<p>I guess I should open an issue about this.</p>
</blockquote>
<p>Yes, please do this.</p>



<a name="242704886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/clippy.toml/near/242704886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jplatte <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/clippy.2Etoml.html#242704886">(Jun 15 2021 at 08:56)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust-clippy/issues/7353">https://github.com/rust-lang/rust-clippy/issues/7353</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>